﻿using Web7.Caching;
using Web7.Configuration;
using Web7.Context;

namespace Web7.Ioc.DemandBuilders
{
    /// <summary>
    /// 框架安装初始化，建立依赖Map
    /// 功能：异常、日志、缓存、多语言、Task.
    /// 详情请见 <see cref="IFrameworkContext"/> we7 框架上下文
    /// </summary>
    public class FrameworkSetup : IDependencyDemandBuilder
    {
        #region Implementation of IDependencyDemandBuilder

        public void Build(IWeb7ContainerBuilder containerBuilder, IBuilderContext context)
        {
            containerBuilder.For<DefaultConfigurationResolver>().KnownAs<IConfigurationResolver>().ScopedAs.Singleton();

            //todo:框架层面的setup (web7)
            //缓存注册
            containerBuilder.ForInstanceOfType<ICacheManager>(DefaultCacheManager.Instance()).ScopedAs.Singleton();
            //new LocalizationSetup().Build(containerBuilder, context); //todo:多语言（勾立国）,异常、日志（陈计节）、task

            //框架上下文服务注册
            containerBuilder.For<Web7FrameworkContext>().KnownAs<IFrameworkContext>().ScopedAs.Singleton();
        }

        #endregion
    }
}
